package com.fuxin.app.services;

import com.fuxin.app.dao.StudentRepository;
import com.fuxin.app.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

/**
 * @Author fuxin
 * @date 2019/2/16 15:55
 * @description
 */
@Service
public class StudentService {

	@Autowired
	StudentRepository repository;

	public Iterable<Student> studentTest(){
		System.out.println(repository.findAll(new PageRequest(1,10)));
		System.out.println(repository.findById(1L));
		System.out.println(repository.count());
		System.out.println(repository.existsById(1L));

//		Student stu = new Student();
//		stu.setName("ck");
//		stu.setBag(new Bag(2, "ck's bag"));
//		stu.setSchool(new School(2,"ssk"));
//
//		System.out.println(repository.save(stu));
//		repository.deleteAll();
//		repository.deleteById(1);
		return repository.findAll();
	}
}
